package com.sefer.dragonfly.client.confige;

import org.apache.commons.digester.Rule;

import com.sefer.dragonfly.client.core.domain.CmConsumer;

public class PluginRule extends Rule {


    @Override
    public void body(String text) throws Exception {
        CmConsumer plugin = null;
        Class<?> newClass = Class.forName(text);

        if (newClass != null && CmConsumer.class.isAssignableFrom(newClass)) {
            Object newInstance = newClass.newInstance();
            if (newInstance != null) {
                plugin = (CmConsumer) newInstance;
            }
        }

        digester.push(plugin);
    }
}
